#include #include using namespace std; void removePunctuation(string& phrase) { //remove punctuation for(int i = 0; i < phrase.length(); i++) { if(phrase[i] == '.' || phrase[i] == ',' || phrase[i] == '?' || phrase[i] == '!' || phrase[i] == ':' || phrase[i] == ';') { phrase.replace(i,1,""); i--; } } } void main() { string phrase; getline(cin,phrase); removePunctuation(phrase); int index = -1; int previousIndex = -1; int palindromeCount = 0; do { index = phrase.find(' ', index + 1); if(index != string::npos) { int wordLength = index - previousIndex; string word = phrase.substr(previousIndex + 1, wordLength); previousIndex = index; cout << word << endl; //if(isPalindrome(word)) //{ // palindromeCount++; //} } else { //at the end of the phrase string word = phrase.substr(previousIndex + 1); cout << word << endl; } } while(index != string::npos); cout << phrase << endl; //removeSpaces(phrase); } //int main(int argc, char* argv[]) //{ // for(int i = 1; i < argc; i++) // { // cout << argv[i] << " "; // } // cout << " = "; // // return 0; //}